package pers.corvey.crawler.extract;

import java.io.IOException;

import pers.corvey.crawler.model.json.MovieJson;
import pers.corvey.crawler.model.json.MovieResultJson;
import pers.corvey.crawler.util.DoubanMovieAPIUtils;
import pers.corvey.crawler.util.JsonUtils;

public class MovieExtract {
	
	public static MovieJson getMovieById(String id) throws IOException {
		String api = DoubanMovieAPIUtils.getMovieInfo(id);
		return JsonUtils.getObjectFromAPI(api, MovieJson.class);
	}
	
	public static MovieResultJson findMovies(String keyword, String tag, int start) 
			throws IOException {
		String api = DoubanMovieAPIUtils.findMovies(keyword, tag, start);
		return JsonUtils.getObjectFromAPI(api, MovieResultJson.class);
	}
	
	public static MovieResultJson getTop250(int start) throws IOException {
		String api = DoubanMovieAPIUtils.getTop250(start);
		return JsonUtils.getObjectFromAPI(api, MovieResultJson.class);
	}
	
	public static MovieResultJson getInTheaters(String city, int start) 
			throws IOException {
		String api = DoubanMovieAPIUtils.getInTheaters(city, start);
		return JsonUtils.getObjectFromAPI(api, MovieResultJson.class);
	}
	
	public static MovieResultJson getComingSoon(int start) throws IOException {
		String api = DoubanMovieAPIUtils.getComingSoon(start);
		return JsonUtils.getObjectFromAPI(api, MovieResultJson.class);
	}

}
